﻿
/*end 信息提示*/
var activeDialogId = null;
var childActiveDialogId = null;

function showAlertOk(msg, timeout) {
    asyncbox.tips(msg, 'success', timeout);
}
function showAlertTip(msg, timeout) {
    asyncbox.tips(msg, 'alert', timeout);
}
function showWarningTip(msg, timeout) {
    asyncbox.tips(msg, 'warning', timeout);
}
function showErrorTip(msg, timeout) {
    asyncbox.tips(msg, 'error', timeout);
}
function jqAlert(msg,title, func) {
    asyncbox.alert(msg, title, func);
}
/// func if (action == 'ok')为确认
function jqConfirm(msg,title, func)
{
   asyncbox.confirm(msg, title,func);
}
function ShowDialog(url, title, width, height) {
    activeDialogId = "ifrmpop_11"; //  + new Date().getTime();
    parent.asyncbox.open({
        id: activeDialogId,
        url: url,
        modal: true,
        width: width,
        height: height,
        title: title
    });
}
function ShowDialogEx(url, title, width, height,callFuc) {
    asyncbox.open({
        id:"ifrmpop_12",
        url: url,
        logo:"",
        modal: true,
        width: width,
        height: height,
        title: title,
        callback: callFuc
    });
}
function closeDialog(reload, vl) {
    activeDialogId && parent.$.close(activeDialogId);
   
    if (typeof(loadGrid) != "undefined") reload && loadGrid(vl);
  }
  function closeRefresh(isbool, vl) {
      var vd = parent.window.getWindow(); //$("#mainframe", parent.window.getCurrentTab())[0].contentWindow;
     if(vd !=null)
     if (typeof (vd.closeDialog) != "undefined")
         vd.closeDialog(isbool, vl);
  }

  function chkMoblie(instr) {
      var regex = { mobile: /^(0|86|17951)?(13[0-9]|15[012356789]|18[0236789]|14[57])[0-9]{8}$/ }
      if (!regex.mobile.test(instr)) {
          return false;
      }
      return true;
  }
  //全局应用
  var Global = {
      //#region Cookies
      Cookies: {

          get: function (name) {
              var start = document.cookie.indexOf(name + "=");
              var len = start + name.length + 1;
              if ((!start) && (name != document.cookie.substring(0, name.length))) {
                  return null;
              }
              if (start == -1) return null;
              var end = document.cookie.indexOf(';', len);
              if (end == -1) end = document.cookie.length;
              return unescape(document.cookie.substring(len, end));
          },

          set: function (name, value, expires, path, domain, secure) {
              var today = new Date();
              today.setTime(today.getTime());
              if (expires) {
                  expires = expires * 1000 * 60 * 60 * 24;
              }
              var expires_date = new Date(today.getTime() + (expires));
              document.cookie = name + '=' + escape(value) +
		    ((expires) ? ';expires=' + expires_date.toGMTString() : '') + //expires.toGMTString()
		    ((path) ? ';path=' + path : '') +
		    ((domain) ? ';domain=' + domain : '') +
		    ((secure) ? ';secure' : '');
          },

          del: function (name, path, domain) {
              if (getCookie(name)) document.cookie = name + '=' +
			((path) ? ';path=' + path : '') +
			((domain) ? ';domain=' + domain : '') +
			';expires=Thu, 01-Jan-1970 00:00:01 GMT';
          },

          imageCode: function () {
              return this.get("LKExamImageCode");
          }

      },
      //#region Guid：创建一个唯一的标识
      Guid: {

          //#region random：返回4位随机数值
          random: function () {
              return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
          },
          //#endregion

          //#region get：返回32为随机数值
          get: function () {
              return (this.random() + this.random() + "-" + this.random() + "-" + this.random() + "-" + this.random() + "-" + this.random() + this.random() + this.random());
          },
          //#endregion

          empty: function () {
              return "00000000-0000-0000-0000-000000000000";
          }
      },
      //返回url是所有参数
      getUrlArg: function () {
          var url = location.search; //获取url中"?"符后的字串
          var theRequest = new Object();
          if (url.indexOf("?") != -1) {
              var str = url.substr(1);
              strs = str.split("&");
              for (var i = 0; i < strs.length; i++) {
                  theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
              }
          }   
         return theRequest; 
      },
       //#region String：字符串集合
    String: {

        //#region trim：删除左右两端的空格
        trim: function (str) {
            if (typeof str == "string") {
                return str.trim();
            }
            else {
                Global.Exception.throwNew(str + "不是字符串，无法删除左右两端的空格！");
            }
        },
        //#endregion

        //#region isNullOrEmpty：是否为null为空字符串
        isNullOrEmpty: function (str) {

            if (str == null || typeof str == "undefined" || (typeof str == "string" && str.trim() == "")) {
                return true;
            }
            return false;
        },
        //#endregion

        //#region isUndefined：是否为undefined
        isUndefined: function (value) {
            return typeof value == "undefined"
        },
        //#endregion

        //#region chsEnLen：中英文字符串长度
        chsEnLen: function (str) {
            var nCNLenth = 0;
            var nLenth = str.length;
            for (var i = 0; i < nLenth; i++) {
                if (str.charCodeAt(i) > 255) {
                    nCNLenth += 2;
                }
                else {
                    nCNLenth++;
                }
            }
            return nCNLenth;
        },
        //#endregion

        //#region lowerCase：转为小写字母
        lowerCase: function (str) {
            if (!this.isNullOrEmpty(str)) {
                str = str.toLowerCase();
            }
            return str;
        },
        //#endregion

        //#region upperCase：转为大写字母
        upperCase: function (str) {
            if (!this.isNullOrEmpty(str)) {
                str = str.toUpperCase();
            }
            return str;
        },
        //#endregion

        sub: function (str, startIndex, length) {
            if (typeof str == "string") {
                return str.Substring(startIndex, length);
            }
            else {
                return str;
            }
        }
    }

  };